<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<div class="modal fade" id="doctorModal" tabindex="-1" role="basic" aria-hidden="true">
    <div style="width: 900px;margin: 300px auto;">
        <form id="assignDoctorFormId" action="/orders/assignDoctor" method="post">
            <%--选择的订单id--%>
            <input type="hidden" name="doctorId" id="doctorId"/>

            <input type="hidden" name="orderId" id="selectOrderId"/>
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                    <h4 class="modal-title" style="">选择医生</h4>
                </div>
                <div class="modal-body">
                    <div class="table-scrollable">
                        <table class="table table-striped table-hover table-success">
                            <thead>
                            <tr>
                                <th class="text-center">照片</th>
                                <th class="text-center">姓名</th>
                                <th class="text-center">年龄</th>
                                <th class="text-center">所在科室</th>
                                <th class="text-center">接诊数量</th>
                                <th class="text-center">是否在线</th>
                                <th class="text-center">所在医院</th>
                                <th class="text-center">选择</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:forEach items="${assignListPage.result}" var="doctor" varStatus="vs">
                                <tr class="text-center">
                                        <%--照片--%>
                                    <td>
                                        <c:if test="${not empty doctor.avatarUrl}">
                                            <img style="max-height: 50px;max-width: 50px;width: auto;height: auto;"
                                                 src="<c:url value="/common/showImage?filePath=${doctor.avatarUrl}"></c:url>"
                                                 alt=""/>
                                        </c:if>
                                    </td>
                                        <%--姓名--%>
                                    <td>${doctor.name}</td>
                                        <%--年龄--%>
                                    <td>
                                            ${doctor.age}
                                    </td>
                                        <%--所在科室--%>
                                    <td>${doctor.departmentName}</td>
                                        <%--接诊数量--%>
                                    <td>${doctor.admissionsCount}</td>
                                        <%--是否在线--%>
                                    <td>否</td>
                                        <%--所在医院--%>
                                    <td>${doctor.hospitalName}</td>
                                        <%--选择--%>
                                    <td>
                                        <a href="javascript:;" class="btn btn-info but_width85"
                                           onclick="confirmDoctor(1,'${doctor.doctorsId}')"
                                           id="selectConfirm${doctor.doctorsId}">
                                            <i class="fa"></i>确认选择
                                        </a>
                                        <a href="javascript:;" class="btn default but_width85" style="display: none;"
                                           onclick="confirmDoctor(0,'${doctor.doctorsId}')"
                                           id="selectCancel${doctor.doctorsId}">
                                            <i class="fa"></i>已选择
                                        </a>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn blue but_width55" onclick="assignDoctor()">确定</button>
                    <button type="button" class="btn default but_width55" data-dismiss="modal">取消</button>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="pageination-panel">${assignListPage}</div>
<script>

    function confirmDoctor(operaType, doctorId) {
        if (1 == operaType) {
            //确认选择
            $("#doctorId").val(doctorId);
            $("a[id^='selectConfirm']").show();
            $("a[id^='selectCancel']").hide();
            $("#selectConfirm" + doctorId).hide();
            $("#selectCancel" + doctorId).show();
        } else {
            //取消选择
            $("#doctorId").val('');
            $("a[id^='selectConfirm']").show();
            $("a[id^='selectCancel']").hide();
        }
    }
</script>